﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QuartzNet
{
   public   class KeyWordsTotalService
   {
       private NewsEntities db = new NewsEntities();

       public async Task<bool> InsertKeyWordsRank()
       {
            string sql = "insert into SearchTotals(Id,KeyWords,SearchCounts) select newid(),KeyWords,count(*)  from SearchDetails where DateDiff(day,SearchDetails.SearchDateTime,getdate())<=30 group by SearchDetails.KeyWords";
           return await this.db.Database.ExecuteSqlCommandAsync(sql)>0;
       }

       public async Task<bool> DeleteKeyWordsRank()
       {
            string sql = "truncate table SearchTotals";
            return await this.db.Database.ExecuteSqlCommandAsync(sql) > 0;
        }
   }
}
